2D Visualizations¶
In PyPMT we can make a variety of visualizations over the outlines of Antarctica or Greenland. If we want to create the map of Antarctica we can do the following:
# Create the map and axes using ant_bounds function
ax = PyPMT.ant_bounds()
Or conversely, we can get the outline of Greenland like so:
ax = PyPMT.greenland_bounds()
And we can put a variety of visualizations on top of these maps. For example, if we wanted to plot a circle, make a geographic quadrangle, or label Antarctic landmarks, we can do the following:
# Create the map and axes using ant_bounds function
ax = PyPMT.ant_bounds()
# Draw a circle with a specified center lat/lon and radius
PyPMT.circle_ps(ax, lons = 20, lats = -80, radii = 500, km=True, color='r')
# label Antarctic landmarks
PyPMT.scar_label(ax, ['Totten Glacier', 'Thwaites Glacier'], color = 'purple', fontsize = 15)
# Draw a quadrangle with geoquadps
latlim = [-80, -70]
lonlim = [-80, -60]
PyPMT.geoquad_ps(ax, latlim, lonlim, color='b', linewidth=2)
# Show the plot
plt.show()
Or suppose we want to plot a line between two landmarks. In this example, we get the latitude and longitude for Thwaites Glacier by using the scar_loc function, and then use plot_ps to plot a line between these coordinates and the coordinates of the South Pole.
# Get the coordinates for Thwaites Glacier
[mcmlat, mcmlon] = PyPMT.scar_loc('thwaites glacier')
# Create the map
ax = PyPMT.ant_bounds()
# Label the South Pole and Thwaites Glacier using scar_label
PyPMT.scar_label(ax, 'South Pole', fontsize = 15)
PyPMT.scar_label(ax, 'Thwaites Glacier', fontsize = 15)
# Draw a line between the coordinates for the South Pole and Thwaites Glacier
PyPMT.plot_ps(ax, [-90, mcmlat], [0, mcmlon], color = 'red', linewidth = 2)
# Place text to label East Antarctica
PyPMT.text_ps(-75, 90, 'East Antarctica', fontstyle='italic', color='blue')
# Show the plot
plt.show()
What if we wanted to plot points over a map? We can do so using scatter_ps... oh did we forget to mention that all these functions work for Greenland too?
ax = PyPMT.greenland_bounds()
# lets get some lat/lon pairs over Greenland
lat = [70, 74]
lon = [-50, -30]
# Plot the points on the map. The s parameter controls the size of a point.
PyPMT.scatter_ps(ax, lat, lon, s=100, c='r', alpha=0.8, edgecolors='k', linewidths=0.8) # plot multiple points at once
PyPMT.scatter_ps(ax, 80, -40, s=1000, c='g', alpha = 0.6, edgecolors = 'b', linewidths = 0.9) # or just one if we want
plt.show()
PyPMT offers many options for visualizations, like these cool contour plots! First, lets load in some bedmachine data to generate the plot with.
Suppose we have used xarray to open a BedMachine dataset pertaining to Antarctica, and we name our dataset 'ds'.
ax = PyPMT.ant_bounds()
PyPMT.contour_ps(ds['x'].values, ds['y'].values, ds['surface'].values, ax = ax)
<cartopy.mpl.contour.GeoContourSet at 0x1c2980e8d50>
We can also make a contour plot with fill:
ax = PyPMT.ant_bounds()
PyPMT.contour_ps(ds['x'].values, ds['y'].values, ds['surface'].values, ax = ax, fill = True)
<cartopy.mpl.contour.GeoContourSet at 0x201561f45b0>
We can also generate a psuedocolor plot of our data. Once again, we are using bedmachine data.
ax = PyPMT.ant_bounds()
PyPMT.pcolor_ps(ax, ds['x'].values, ds['y'].values, ds['bed'].values)
plt.show()